From: kaf24@localhost.localdomain Date: Thu, 2 Nov 2006 22:24:20 +0000 (+0000) Subject: [XEN] Add 'loglvl' and 'guest_loglvl' boot parameters. X-Git-Url: https://dgit.raspbian.org/%22http:/www.example.com/cgi/%22https:/%22bookmarks://%22Dat/%22http:/www.example.com/cgi/%22https:/%22bookmarks:/%22Dat?a=commitdiff_plain;h=7be8e242eee700afd5f498f0bb69a03957b6fd36;p=xen.git [XEN] Add 'loglvl' and 'guest_loglvl' boot parameters. := none|error|warning|info|debug|all loglvl=[/] : log level which is always printed : log level which is rate-limit printed 'loglvl' applies to non-guest-related messages. 'guest_loglvl' applies to guest-related messages. Defaults: loglvl=warning ; guest_loglvl=none/warning Also clean up hvm_print_line(). Signed-off-by: Keir Fraser --- diff --git a/docs/src/user.tex b/docs/src/user.tex index 768b22165a..2528861a23 100644 --- a/docs/src/user.tex +++ b/docs/src/user.tex @@ -3192,6 +3192,15 @@ editing \path{grub.conf}. input to DOM0 when it boots --- if it is `x' then auto-switching is disabled. Any other value, or omitting the character, enables auto-switching. [NB. Default switch-char is `a'.] +\item [ loglvl=$<$level$>/<$level$>$ ] + Specify logging level. Messages of the specified severity level (and + higher) will be printed to the Xen console. Valid levels are `none', + `error', `warning', `info', `debug', and `all'. The second level + specifier is optional: it is used to specify message severities + which are to be rate limited. Default is `loglvl=warning'. +\item [ guest\_loglvl=$<$level$>/<$level$>$ ] As for loglvl, but + applies to messages relating to guests. Default is + `guest\_loglvl=none/warning'. \item [ nmi=xxx ] Specify what to do with an NMI parity or I/O error. \\ `nmi=fatal': Xen prints a diagnostic and then hangs. \\ diff --git a/xen/arch/x86/domain.c b/xen/arch/x86/domain.c index f763928010..b484bcebb8 100644 --- a/xen/arch/x86/domain.c +++ b/xen/arch/x86/domain.c @@ -243,6 +243,8 @@ int arch_domain_create(struct domain *d) goto fail; } + spin_lock_init(&d->arch.hvm_domain.pbuf_lock); + rc = shadow_enable(d, SHM2_refcounts|SHM2_translate|SHM2_external); if ( rc != 0 ) goto fail; diff --git a/xen/arch/x86/hvm/hvm.c b/xen/arch/x86/hvm/hvm.c index cc052e823d..4c46a7ea8f 100644 --- a/xen/arch/x86/hvm/hvm.c +++ b/xen/arch/x86/hvm/hvm.c @@ -325,22 +325,22 @@ int hvm_copy_from_guest_virt(void *buf, unsigned long vaddr, int size) return __hvm_copy(buf, shadow_gva_to_gpa(current, vaddr), size, 0); } -/* - * HVM specific printbuf. Mostly used for hvmloader chit-chat. - */ +/* HVM specific printbuf. Mostly used for hvmloader chit-chat. */ void hvm_print_line(struct vcpu *v, const char c) { - int *index = &v->domain->arch.hvm_domain.pbuf_index; - char *pbuf = v->domain->arch.hvm_domain.pbuf; - - if (*index == HVM_PBUF_SIZE-2 || c == '\n') { - if (*index == HVM_PBUF_SIZE-2) - pbuf[(*index)++] = c; - pbuf[*index] = '\0'; - printk("(GUEST: %u) %s\n", v->domain->domain_id, pbuf); - *index = 0; - } else - pbuf[(*index)++] = c; + struct hvm_domain *hd = &v->domain->arch.hvm_domain; + + spin_lock(&hd->pbuf_lock); + hd->pbuf[hd->pbuf_idx++] = c; + if ( (hd->pbuf_idx == (sizeof(hd->pbuf) - 2)) || (c == '\n') ) + { + if ( c != '\n' ) + hd->pbuf[hd->pbuf_idx++] = '\n'; + hd->pbuf[hd->pbuf_idx] = '\0'; + printk(XENLOG_G_DEBUG "HVM%u: %s\n", v->domain->domain_id, hd->pbuf); + hd->pbuf_idx = 0; + } + spin_unlock(&hd->pbuf_lock); } typedef unsigned long hvm_hypercall_t( diff --git a/xen/drivers/char/console.c b/xen/drivers/char/console.c index 5d609d15b0..ddd367878e 100644 --- a/xen/drivers/char/console.c +++ b/xen/drivers/char/console.c @@ -82,13 +82,76 @@ static DEFINE_SPINLOCK(console_lock); #define XENLOG_DEFAULT 1 /* XENLOG_WARNING */ #define XENLOG_GUEST_DEFAULT 1 /* XENLOG_WARNING */ -int xenlog_upper_thresh = XENLOG_UPPER_THRESHOLD; -int xenlog_lower_thresh = XENLOG_LOWER_THRESHOLD; -int xenlog_guest_upper_thresh = XENLOG_GUEST_UPPER_THRESHOLD; -int xenlog_guest_lower_thresh = XENLOG_GUEST_LOWER_THRESHOLD; +static int xenlog_upper_thresh = XENLOG_UPPER_THRESHOLD; +static int xenlog_lower_thresh = XENLOG_LOWER_THRESHOLD; +static int xenlog_guest_upper_thresh = XENLOG_GUEST_UPPER_THRESHOLD; +static int xenlog_guest_lower_thresh = XENLOG_GUEST_LOWER_THRESHOLD; + +static void parse_loglvl(char *s); +static void parse_guest_loglvl(char *s); + +/* + * := none|error|warning|info|debug|all + * loglvl=[/] + * : log level which is always printed + * : log level which is rate-limit printed + * Similar definitions for guest_loglvl, but applies to guest tracing. + * Defaults: loglvl=warning ; guest_loglvl=none/warning + */ +custom_param("loglvl", parse_loglvl); +custom_param("guest_loglvl", parse_guest_loglvl); static int xen_startup = 1; +#define ___parse_loglvl(s, ps, lvlstr, lvlnum) \ + if ( !strncmp((s), (lvlstr), strlen(lvlstr)) ) { \ + *(ps) = (s) + strlen(lvlstr); \ + return (lvlnum); \ + } + +static int __parse_loglvl(char *s, char **ps) +{ + ___parse_loglvl(s, ps, "none", 0); + ___parse_loglvl(s, ps, "error", 1); + ___parse_loglvl(s, ps, "warning", 2); + ___parse_loglvl(s, ps, "info", 3); + ___parse_loglvl(s, ps, "debug", 4); + ___parse_loglvl(s, ps, "all", 4); + return 2; /* sane fallback */ +} + +static void _parse_loglvl(char *s, int *lower, int *upper) +{ + *lower = *upper = __parse_loglvl(s, &s); + if ( *s == '/' ) + *upper = __parse_loglvl(s+1, &s); + if ( *upper < *lower ) + *upper = *lower; +} + +static void parse_loglvl(char *s) +{ + _parse_loglvl(s, &xenlog_lower_thresh, &xenlog_upper_thresh); +} + +static void parse_guest_loglvl(char *s) +{ + _parse_loglvl(s, &xenlog_guest_lower_thresh, &xenlog_guest_upper_thresh); +} + +static char *loglvl_str(int lvl) +{ + switch ( lvl ) + { + case 0: return "Nothing"; + case 1: return "Errors"; + case 2: return "Errors and warnings"; + case 3: return "Errors, warnings and info"; + case 4: return "All"; + } + return "???"; +} + /* * ******************************************************** * *************** ACCESS TO CONSOLE RING ***************** @@ -450,6 +513,14 @@ void console_endboot(void) { int i, j; + printk("Std. Loglevel: %s", loglvl_str(xenlog_lower_thresh)); + if ( xenlog_upper_thresh != xenlog_lower_thresh ) + printk(" (Rate-limited: %s)", loglvl_str(xenlog_upper_thresh)); + printk("\nGuest Loglevel: %s", loglvl_str(xenlog_guest_lower_thresh)); + if ( xenlog_guest_upper_thresh != xenlog_guest_lower_thresh ) + printk(" (Rate-limited: %s)", loglvl_str(xenlog_guest_upper_thresh)); + printk("\n"); + if ( opt_sync_console ) { printk("**********************************************\n"); diff --git a/xen/include/asm-x86/hvm/domain.h b/xen/include/asm-x86/hvm/domain.h index 0ebec779c1..ddcd2d12ee 100644 --- a/xen/include/asm-x86/hvm/domain.h +++ b/xen/include/asm-x86/hvm/domain.h @@ -28,8 +28,6 @@ #include #include -#define HVM_PBUF_SIZE 80 - struct hvm_domain { unsigned long shared_page_va; unsigned long buffered_io_va; @@ -45,8 +43,10 @@ struct hvm_domain { spinlock_t round_robin_lock; int interrupt_request; - int pbuf_index; - char pbuf[HVM_PBUF_SIZE]; + /* hvm_print_line() logging. */ + char pbuf[80]; + int pbuf_idx; + spinlock_t pbuf_lock; uint64_t params[HVM_NR_PARAMS]; }; diff --git a/xen/include/xen/lib.h b/xen/include/xen/lib.h index 6327f3106e..e05eac28a9 100644 --- a/xen/include/xen/lib.h +++ b/xen/include/xen/lib.h @@ -58,10 +58,6 @@ extern void panic(const char *format, ...) extern long vm_assist(struct domain *, unsigned int, unsigned int); extern int __printk_ratelimit(int ratelimit_ms, int ratelimit_burst); extern int printk_ratelimit(void); -extern int xenlog_upper_thresh; -extern int xenlog_lower_thresh; -extern int xenlog_guest_upper_thresh; -extern int xenlog_guest_lower_thresh; /* vsprintf.c */ extern int sprintf(char * buf, const char * fmt, ...)